#ifndef _CRT_COMUTIL_HPP_
#define _CRT_COMUTIL_HPP_

#ifndef _HRESULT_DEFINED
#define _HRESULT_DEFINED


#if (TARGET_OS == OS_DARWIN)
    //cocoa/foundation/CFPlugin.h ==> macosx com 
    #ifndef __COREFOUNDATION_CFPLUGINCOM__
    typedef long HRESULT;
    #endif
#elif (TARGET_OS == OS_POSIX)
    typedef long HRESULT;
#elif (TARGET_OS == OS_POSIX)
    typedef long HRESULT;
#endif



#endif


#ifndef S_SUCCESS								
#define S_SUCCESS								0
#endif	// !S_SUCCESS

#ifndef S_ERROR									
#define S_ERROR									1
#endif	// !S_ERROR

#ifndef S_FAILD									
#define S_FAILD									10
#endif	// !S_FAILD

#ifndef S_TIMEOUT		
#define S_TIMEOUT								100
#endif	// !S_TIMEOUT

#ifndef S_OK
#define S_OK									((HRESULT)0L)
#endif // !S_OK

#ifndef S_FALSE
#define S_FALSE									((HRESULT)1L)
#endif // !S_FALSE

#ifndef S_DELETE
#define S_DELETE								((HRESULT)10L)
#endif // !S_DELETE

#ifndef S_SUCCEEDED
#define S_SUCCEEDED(hr)							((HRESULT)(hr) == S_OK)
#endif

#ifndef S_FAILED
#define S_FAILED(hr)							((HRESULT)(hr) != S_OK)
#endif

#ifndef PURE
#define PURE									= 0
#endif


#if (TARGET_OS == OS_WINDOWS)
#define MODULE_API                              HRESULT	OS_STDCALL 
#elif (TARGET_OS == OS_POSIX)
#define MODULE_API                              HRESULT _VISIBILITY_DEFAULT 
#define E_NOTIMPL					            1002
#define E_OUTOFMEMORY							1003
#define E_INVALIDARG							1004
#define E_NOINTERFACE							1005
#define E_FAIL									1009
#elif (TARGET_OS == OS_DARWIN)
#define MODULE_API                              HRESULT _VISIBILITY_DEFAULT 
#define E_NOTIMPL	                            1002
#define E_OUTOFMEMORY							1003
#define E_INVALIDARG							1004
#define E_NOINTERFACE							1005
#define E_FAIL								    1009
#endif


#define std_method(method) 			virtual HRESULT OS_STDCALL method
#define std_method_impl				HRESULT OS_STDCALL
#define std_method_(type,method)	virtual type OS_STDCALL method
#define std_method_type_impl(type)	type OS_STDCALL  
#define std_com_export				EXTERN_C MODULE_API




#endif


